#!/usr/bin/env python
# -*- encoding: utf-8 -*-

"""
@File : sequence_feat.py
@Author : Braylon1002
@Version : 1.0
@Contact : S.Braylon1002@gmail.com
Desc : None
"""
from .base import BaseFeature

class Sequence(BaseFeature):
    """
    class for sequence features
    like: hist...
    """
    def __init__(self, name, column_flow,
                 embedding_name=None, embedding_size=None,
                 vocab_size=None, max_length=None):
        super().__init__(name, column_flow)
        self.embedding_name = embedding_name if embedding_name else name
        self.embedding_size = embedding_size
        self.vocab_size = vocab_size
        self.max_length = max_length

    def dimension(self):
        if self.column_flow:
            return self.column_flow.transformers[-1].dimension()
        else:
            if self.vocab_size:
                return self.vocab_size
            else:
                raise RuntimeError(
                    "missing dimension which depends on column_flow or vocab_size"
                )

    def max_length(self):
        if self.column_flow:
            return self.column_flow.transformers[-1].max_length()
        else:
            if self.max_length():
                return self.max_length()
            else:
                raise RuntimeError(
                    "missing max_lenth which depends on column_flow or max_length"
                )